package homework01;


import java.util.Comparator;
import java.util.Random;
import java.util.TreeSet;

public class Test01 {
    public static void main(String[] args) {
       //随机数导包
        Random random = new Random();
        //创建TreeSet集合
        TreeSet<Integer> treeSet=new TreeSet<>();
        //循环数组，将随机数赋值到集合中
        while (treeSet.size()<10){
            treeSet.add(random.nextInt(51));
        }
        System.out.println(treeSet);
        //创建TreeSet集合
        //重写
        TreeSet<Integer> treeSet1=new TreeSet<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2-o1;
            }
        });
        //循环数组，将随机数赋值到集合中
       while (treeSet1.size()<10){
            treeSet1.add(random.nextInt(51)+50);
        }

        System.out.println(treeSet1);



    }
}
